using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ACME.Northwind.DataTransfer;
using ACME.Northwind.Service.Interfaces;
using ACME.Northwind.MockProxy.EventArgs;

namespace ACME.Northwind.MockProxy
{
	/// <summary>
	/// The service implementation for OrderDetail object
	/// </summary>
	public partial class OrderDetailService : IOrderDetailService
	{
		#region IOrderDetailService Members

		/// <summary>
		/// Run the mock for the select by the primary key
		/// </summary>
		public OrderDetailDTO SelectByPrimaryKey(int orderid, int productid)
		{
			OrderDetailPrimaryKeyEventArgs eventArgs = new OrderDetailPrimaryKeyEventArgs(orderid, productid);
			this.OnMockOrderDetailSelectByPrimaryKey(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Run the mock for select all
		/// </summary>
		public List<OrderDetailDTO> RunSelect()
		{
			OrderDetailRunSelectEventArgs eventArgs = new OrderDetailRunSelectEventArgs();
			this.OnMockOrderDetailRunSelect(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Run the mock for select with LINQ
		/// </summary>
		public List<OrderDetailDTO> RunSelect(string linq)
		{
			OrderDetailRunSelectLINQEventArgs eventArgs = new OrderDetailRunSelectLINQEventArgs(linq);
			this.OnMockOrderDetailRunSelectLINQ(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Run the mock for paged select
		/// </summary>
		public PagedQueryResults<OrderDetailDTO> RunSelect(int pageIndex, int pageSize, bool ascending, string sortColumn, string linq)
		{
			OrderDetailRunSelectPagedEventArgs eventArgs = new OrderDetailRunSelectPagedEventArgs(pageIndex, pageSize, ascending, sortColumn, linq);
			this.OnMockOrderDetailRunSelectPaged(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Return the related Order item
		/// </summary>
		public OrderDTO GetOrderItem(OrderDetailDTO item)
		{
			OrderDTO retval = new OrderDTO();
			OrderDetailDTOEventArgs eventArgs = new OrderDetailDTOEventArgs(item);
			this.OnMockGetOrderItem(eventArgs);
			retval = (OrderDTO)eventArgs.ReturnDTOItem;
			return retval;
		}

		/// <summary>
		/// Return the related Product item
		/// </summary>
		public ProductDTO GetProductItem(OrderDetailDTO item)
		{
			ProductDTO retval = new ProductDTO();
			OrderDetailDTOEventArgs eventArgs = new OrderDetailDTOEventArgs(item);
			this.OnMockGetProductItem(eventArgs);
			retval = (ProductDTO)eventArgs.ReturnDTOItem;
			return retval;
		}

		/// <summary>
		/// Persists a single item
		/// </summary>
		public bool Persist(OrderDetailDTO dto)
		{
			OrderDetailPersistEventArgs eventArgs = new OrderDetailPersistEventArgs(dto);
			this.OnMockOrderDetailPersist(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Persists a list
		/// </summary>
		public bool Persist(List<OrderDetailDTO> list)
		{
			OrderDetailPersistEventArgs eventArgs = new OrderDetailPersistEventArgs(list);
			this.OnMockOrderDetailPersist(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Delete a single item
		/// </summary>
		public bool Delete(OrderDetailDTO dto)
		{
			OrderDetailDeleteEventArgs eventArgs = new OrderDetailDeleteEventArgs(dto);
			this.OnMockOrderDetailDelete(eventArgs);
			return eventArgs.ReturnValue;
		}

		#endregion

		#region OrderDetail Events

		partial void GetSelectByPrimaryKey();

		/// <summary>
		/// The event for the SelectByPrimaryKey method
		/// </summary>
		public event EventHandler<OrderDetailPrimaryKeyEventArgs> MockOrderDetailSelectByPrimaryKey;

		/// <summary>
		/// Raises the OnMockRegistrationCodeSelectByPrimaryKey event
		/// </summary>
		protected virtual void OnMockOrderDetailSelectByPrimaryKey(OrderDetailPrimaryKeyEventArgs e)
		{
			if (this.MockOrderDetailSelectByPrimaryKey != null)
				this.MockOrderDetailSelectByPrimaryKey(this, e);
		}

		/// <summary>
		/// The event for the RunSelect method
		/// </summary>
		public event EventHandler<OrderDetailRunSelectEventArgs> MockOrderDetailRunSelect;

		/// <summary>
		/// Raises the OnMockRunSelect event
		/// </summary>
		protected virtual void OnMockOrderDetailRunSelect(OrderDetailRunSelectEventArgs e)
		{
			if (this.MockOrderDetailRunSelect != null)
				this.MockOrderDetailRunSelect(this, e);
		}

		/// <summary>
		/// The event for the RunSelectLINQ method
		/// </summary>
		public event EventHandler<OrderDetailRunSelectLINQEventArgs> MockOrderDetailRunSelectLINQ;

		/// <summary>
		/// The event for the OnMockRunSelectLINQ method
		/// </summary>
		protected virtual void OnMockOrderDetailRunSelectLINQ(OrderDetailRunSelectLINQEventArgs e)
		{
			if (this.MockOrderDetailRunSelectLINQ != null)
				this.MockOrderDetailRunSelectLINQ(this, e);
		}

		/// <summary>
		/// The event for the RunSelectPaged method
		/// </summary>
		public event EventHandler<OrderDetailRunSelectPagedEventArgs> MockOrderDetailRunSelectPaged;

		/// <summary>
		/// The event for the OnMockRunSelectPaged method
		/// </summary>
		protected virtual void OnMockOrderDetailRunSelectPaged(OrderDetailRunSelectPagedEventArgs e)
		{
			if (this.MockOrderDetailRunSelectPaged != null)
				this.MockOrderDetailRunSelectPaged(this, e);
		}

		/// <summary>
		/// The event for the GetOrderItem method
		/// </summary>
		public event EventHandler<OrderDetailDTOEventArgs> MockGetOrderItem;

		/// <summary>
		/// The event for the OnMockGetOrderItem method
		/// </summary>
		protected virtual void OnMockGetOrderItem(OrderDetailDTOEventArgs e)
		{
			if (this.MockGetOrderItem != null)
				this.MockGetOrderItem(this, e);
		}

		/// <summary>
		/// The event for the GetProductItem method
		/// </summary>
		public event EventHandler<OrderDetailDTOEventArgs> MockGetProductItem;

		/// <summary>
		/// The event for the OnMockGetProductItem method
		/// </summary>
		protected virtual void OnMockGetProductItem(OrderDetailDTOEventArgs e)
		{
			if (this.MockGetProductItem != null)
				this.MockGetProductItem(this, e);
		}

		/// <summary>
		/// The event for the Persist method
		/// </summary>
		public event EventHandler<OrderDetailPersistEventArgs> MockOrderDetailPersist;

		/// <summary>
		/// Raises the OnMockPersist event
		/// </summary>
		protected virtual void OnMockOrderDetailPersist(OrderDetailPersistEventArgs e)
		{
			if (this.MockOrderDetailPersist != null)
				this.MockOrderDetailPersist(this, e);
		}

		/// <summary>
		/// The event for the Delete method
		/// </summary>
		public event EventHandler<OrderDetailDeleteEventArgs> MockOrderDetailDelete;

		/// <summary>
		/// Raises the OnMockDelete event
		/// </summary>
		protected virtual void OnMockOrderDetailDelete(OrderDetailDeleteEventArgs e)
		{
			if (this.MockOrderDetailDelete != null)
				this.MockOrderDetailDelete(this, e);
		}

		#endregion

	}
}
